package com.wwdx.controller.admin;

import com.wwdx.controller.base.BaseController;
import com.wwdx.model.WwdxOrderModel;
import com.wwdx.model.dto.ResultBean;
import com.wwdx.utils.ConstantHolder;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * @author liguoliang
 * @date 2016/11/5.
 */
@Controller
@RequestMapping("/system/wwdx_order")
public class WwdxOrderController extends BaseController{

    @RequestMapping("/index")
    public ModelAndView index(){
        return new ModelAndView();
    }

    /**
     * 列表
     */
    @RequestMapping("/list")
    @ResponseBody
    public Map<String,Object> list(WwdxOrderModel model,
                                   @RequestParam(value = "page", defaultValue = "1") Integer page,
                                   @RequestParam(value = "rows", defaultValue = "10") Integer rows) {

        Map<String,Object> map = new HashMap<>(2);
        map.put("total",  wwdxOrderService.selectModelCount(model));
        map.put("rows",  wwdxOrderService.selectModelList(model,page,rows));
        return map;
    }

    /**
     * 发送邮件
     */
    @RequestMapping("/export")
    @ResponseBody
    public ResultBean export(String email){
        boolean result = taskService.sendEmail(ConstantHolder.Constant.PRE_WWDXORDER,email,"订单统计信息");
        return renderSuccess(result);
    }
}